home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 712 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: gabi-soft.fr!usenet
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Initializing a variable in terms of itself
  5. Date: 09 Apr 1996 10:59:38 GMT
  6. Organization: GABI Software, Sarl.
  7. Message-ID: <KANZE.96Apr9125938@gabi.gabi-soft.fr>
  8. References: <4jpj9l$ik9@cnn.Princeton.EDU> <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de>
  9.     <4k65h6$dfe@nntp.crl.com>
  10. NNTP-Posting-Host: gabi.gabi-soft.fr
  11. In-reply-to: tmcd@crl.com's message of 6 Apr 1996 16:18:46 GMT
  12.  
  13. In article <4k65h6$dfe@nntp.crl.com> tmcd@crl.com (Timothy A. McDaniel)
  14. writes:
  15.  
  16. |> In article <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de>,
  17. |> James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:
  18. |> >In article <4jpj9l$ik9@cnn.Princeton.EDU> tim@franck (Tim Hollebeek)
  19. |> >writes:
  20. |> ...
  21. |> >|>     int x = x;
  22. |> ...
  23. |> >The reference to `x' in the initialization expression is not, per se,
  24. |> >illegal.  The variable is declared, and available for use, as soon as
  25. |> >the compiler sees the `=' sign.
  26.  
  27. |> So
  28. |>     void *x = &x;
  29. |> would be legal,
  30.  
  31. Exactly.
  32.  
  33. |> then, and x would point to itself?  (Or would it have
  34. |> to be
  35. |>     void *x = (void *) &x;
  36. |> ?)
  37.  
  38. The cast is not necessary.
  39.  
  40. I've even used this sort of thing in the past:
  41.  
  42.     struct NODE
  43.     {
  44.         NODE*           next ;
  45.         NODE*           prec ;
  46.     } ;
  47.  
  48.     struct NODE     root = { &root , &root } ;
  49.  
  50. Note that despite the added braces, etc., this is really just a variant
  51. of the same theme.
  52. -- 
  53. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  54. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  55. Conseils en informatique industrielle --
  56.                             -- Beratung in industrieller Datenverarbeitung
  57.